package com.atguigu.gmall.cart.api;

import com.atguigu.gmall.cart.model.CartInfo;
import com.atguigu.gmall.cart.service.CartInfoService;
import com.atguigu.gmall.order.model.OrderDetail;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: atguigu
 * @create: 2023-08-10 09:37
 */
@RestController
@RequestMapping("/api/cart")
public class CartApiController {

    @Autowired
    private CartInfoService cartInfoService;


    /**
     * 根据用户ID，查询用户购物车商品，将CartInfo转为OrderDetail对象
     *
     * @param userId
     * @return
     */
    @ApiOperation("根据用户ID，查询用户购物车商品，将CartInfo转为OrderDetail对象")
    @GetMapping("/getCartCheckedList/{userId}")
    public List<OrderDetail> getCartCheckedList(@PathVariable("userId") Long userId) {
        return cartInfoService.getCartCheckedList(userId);
    }
}
